package nosgoth.com.games.touche;
 
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

public class BoardAdapter extends BaseAdapter implements OnClickListener
{    
	private final String[] Fields = {"", "", "", "KD", "6D"};   
	private Context _context;    
	
	public BoardAdapter(Context c) {        
		_context = c;    
	}    
	
	public int getCount() {        
		return 144;    
	}    
	
	public Object getItem(int position) {        
		return null;    
	}    
	
	public long getItemId(int position) {        
		return 0;    
	}    
	
	// create a new Button for each item referenced by the Adapter    
	public View getView(int position, View convertView, ViewGroup parent) {        
		Button button;        
		if (convertView == null) {  
			// if it's not recycled, initialize some attributes            
			button = new Button(_context);      
			
			if (position >= 0 && position <= 2
				|| position >= 9 && position <= 14
				|| position >= 21 && position <= 25
				|| position >= 34 && position <= 35
				|| position >= 108 && position <= 109
				|| position >= 118 && position <= 122
				|| position >= 129 && position <= 134
				|| position >= 141 && position <= 143) {
				button.setBackgroundResource(R.drawable.button_pressed);
				button.setClickable(false);
				button.setOnClickListener(this);
			} else {
				button.setBackgroundResource(R.drawable.board_button);
				if (Fields.length > position)
					button.setText(Fields[position].substring(0, 1));
			}
		} else {            
			button = (Button) convertView;        
		}        
		
		return button;    
	}

	public void onClick(View view) {
		// TODO Auto-generated method stub
		
	}    
}